package edu.ynu.se.xiecheng.achitectureclass.project.po.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Entity
@Getter
@Setter
@Table(name = "Greenhouse")
public class Greenhouse extends LogicEntity {

    @Column(name = "box_id")
    private String boxId;

    @Column(name = "name")
    private String name;

    @Column(name = "address")
    private String address;

    @Column(name = "area")
    private Double area;

    @Column(name = "timestamp")
    private Date timestamp;

    // 一对多关系：大棚与设备
    @OneToMany(mappedBy = "greenhouse", cascade = CascadeType.ALL, orphanRemoval = true)
    @JsonManagedReference
    private List<Device> devices;
}
